#include<bits/stdc++.h>
#define gc getchar
#define pc putchar
using namespace std;
int read(){
    int x=0,f=1;
    char ch=gc();
    while(!isdigit(ch) && ch!='-')ch=gc();
    if(ch=='-'){
        f=-1;
        ch=gc();
    }
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+(ch^48);
        ch=gc();
    }
    return x*f;
}
void print(int x){
    if(x<0){
        pc('-');
        x=-x;
    }
    if(x<10){
        pc(x^48);
        return;
    }
    print(x/10);
    pc((x%10)^48);
}
int chose[50];
int c[50];
int a[50];
int n;
int ans=-1;
void dfs(int dep){
    if(dep>n){
        for(int i=1;i<=n;i++){
            int flg=-1;
            for(int j=i-1;j>=1;j--){
                if(chose[j]==chose[i]){
                    flg=j;break;
                }
            }
            if(flg!=-1 && a[flg]==a[i])c[i]=a[i];
            else c[i]=0;
        }
        int now=0;
        for(int i=1;i<=n;i++)now+=c[i];
       // cout<<"now:"<<now<<endl;
        ans=max(ans,now);
        return;
    }
    for(int i=0;i<=1;i++){
        chose[dep]=i;
        dfs(dep+1);
    }
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T=read();
    while(T--){
        n=read();
        ans=-1;
        for(int i=1;i<=n;i++)a[i]=read();
        dfs(1);
        print(ans),pc('\n');
    }
}
/*
STO TheSky233 Orz
STO LXGOD Orz
STO rym Orz
STO czx Orz
rp+=inf;
rp+=inf;
rp+=inf;
rp+=inf;
rp+=inf;
rp+=inf;rp++;
luogu_uid=1038710
STO give me 1= please Orz
*/
